package com.gxa.controller.shezhicontroller;

import com.gxa.common.R;
import com.gxa.pojo.CangKu;
import com.gxa.pojo.CangKuSheZhi;
import com.gxa.service.shezhiservice.CangKuSheZhiService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author weishen
 */
@RestController
@RequestMapping("/CangKu")
@Api(value = "仓库管理" , tags = "仓库数据接口API")
@RequiresPermissions("仓库设置")
public class CangKuSheZhiController {

    @Autowired
    CangKuSheZhiService cangKuSheZhiService;

//    @ApiOperation(value = "查询所有供应商信息接口",notes = "提供页码和每页显示数",httpMethod = "get",response = R.class)
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
//            @ApiImplicitParam(name = "size",value = "每页显示数",required = true,dataType = "int",paramType = "query"),
//
//    })
//    @ApiResponses({
//            @ApiResponse(code=200,message="请求成功"),
//            @ApiResponse(code=404,message="找不到页面"),
//            @ApiResponse(code=500,message="后台服务错误")
//    })
    @Autowired(required = false)
    public R r;
    @GetMapping("/selectAllCangKuForPage")
    @ApiOperation(value = "查询所有仓库信息接口",notes = "提供页码和每页显示数",httpMethod = "get",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "size",value = "每页显示数",required = true,dataType = "int",paramType = "query"),

    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R selectAllCangKuForPage(@RequestParam int page,@RequestParam int size)
    {
        return cangKuSheZhiService.selectAllCangKuForPage(page, size);
    }

    @PostMapping("/updateCangKuById")
    @ApiOperation(value="修改仓库信息接口",notes = "提供仓库信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R updateCangKuById(@RequestBody CangKuSheZhi cangKu)
    {

        return cangKuSheZhiService.updateCangKuById(cangKu);
    }

    @PostMapping("/insertCangKu")
    @ApiOperation(value="新增仓库接口",notes="提供仓库信息",httpMethod = "post",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R insertCangKu(@RequestBody CangKuSheZhi cangKu)
    {
        return cangKuSheZhiService.insertCangKu(cangKu);
    }
    @PostMapping("/deleteCangKuById")
    @ApiOperation(value = "删除仓库接口",notes = "提供仓库id",httpMethod = "get",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteCangKuById(@RequestParam ArrayList<Integer> id)
    {
        return cangKuSheZhiService.deleteCangKuById(id);
    }
}
